package com.ppl.server.db;

import com.github.jmkgreen.morphia.Datastore;
import com.github.jmkgreen.morphia.Morphia;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.mongodb.DB;
import com.mongodb.Mongo;

import java.net.UnknownHostException;

/**
 * User: Vincent
 * Date: 11/13/12
 * Time: 6:03 PM
 */
public class DatastoreProvider implements Provider<Datastore> {
    @Inject
    private Morphia morphia;

    @Override
    public Datastore get() {
        try {
            Mongo mongo = new Mongo("localhost");
            Datastore ds = morphia.createDatastore(mongo,"ppl");
            return ds;
        } catch (UnknownHostException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        return null;
    }
}
